import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { maintenancePlanVO, maintenancePlanForm, maintenancePlanQuery } from '@/api/maintenance/maintenance-plan/types';

/**
 * 查询设备维保-计划列表
 * @param query
 * @returns {*}
 */

export const listmaintenancePlan = (query?: maintenancePlanQuery): AxiosPromise<maintenancePlanVO[]> => {
  return request({
    url: '/maintenance/maintenance-plan/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备维保-计划详细
 * @param equipmentMaintenancePlanId
 */
export const getmaintenancePlan = (equipmentMaintenancePlanId: string | number): AxiosPromise<maintenancePlanVO> => {
  return request({
    url: '/maintenance/maintenance-plan/' + equipmentMaintenancePlanId,
    method: 'get'
  });
};

/**
 * 新增设备维保-计划
 * @param data
 */
export const addmaintenancePlan = (data: maintenancePlanForm) => {
  return request({
    url: '/maintenance/maintenance-plan',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备维保-计划
 * @param data
 */
export const updatemaintenancePlan = (data: maintenancePlanForm) => {
  return request({
    url: '/maintenance/maintenance-plan',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备维保-计划
 * @param equipmentMaintenancePlanId
 */
export const delmaintenancePlan = (equipmentMaintenancePlanId: string | number | Array<string | number>) => {
  return request({
    url: '/maintenance/maintenance-plan/' + equipmentMaintenancePlanId,
    method: 'delete'
  });
};
